<!DOCTYPE html>
<html style="background: #eee">
<head lang="en">
    <meta charset="UTF-8">
    <meta name='apple-touch-fullscreen' content='yes'>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta content="fullscreen=yes,preventMove=no" name="ML-Config">
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="format-detection" content="telephone=no,email=no,address=no"/>
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>转账管理</title>
    <link rel="stylesheet" href="/style/lh/css/style.css">
    <link type="text/css" rel="stylesheet" href="/style/css/sweet-alert.css">
    <script src="/style/wei/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/style/lh/js/style.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/style/js/sweet-alert.min.js"></script>
    <script type="text/javascript">     
    (function () {
        var b = document.documentElement,
            a = function () {
                var a = b.getBoundingClientRect().width;
                b.style.fontSize = (a / 1080) * 100+ "px";
            }, c = null;
        window.addEventListener("resize", function () {
            clearTimeout(c);
            c = setTimeout(a, 300);
        });
        a();
    })();
    </script>
    <style>
    .b-input>input{display: none;}
    .b-input>label{ position: relative; margin-right:0.8rem;font-size: 0.4rem; color: #333;}
    .b-input>label::before{ display: inline-block; content: ""; width: 16px; height: 16px; border-radius: 50%; background-color: #f2f2f2; margin-right: 0.12rem; vertical-align: middle;}
    .b-input>input:checked+label::before{ border: 1px solid rgb(219, 219, 219);}
    .b-input>input:checked+label::after{ display: inline-block; content: ""; width: 8px; height: 8px; border-radius: 50%; position: absolute; left: 5px; bottom: 5px; background-color:#e14504;}
    </style>
    </head>
<body>
<form id="form_tx">
    <div class="b-bg">
        <h3 id="user_text">硒豆余额</h3>
        <h2 id="user_money"><?=($this->data['money']*1)?></h2>
    </div>
    <div class="b-navbar">
        <dl>
             <dd class="b-input">
                <i>转账类型：</i>
                <input type="radio" name="type" id="paixu1" value="1" checked>
                <label for="paixu1" style="cursor:pointer">硒豆</label>
                <input type="radio" name="type" id="paixu2" value="2">
                <label for="paixu2" style="cursor:pointer">硒米</label>
                <input type="radio" name="type" id="paixu3" value="3">
                <label for="paixu3" style="cursor:pointer">金花</label>
            </dd>
            <dd>
                <i>转入帐号：</i>
                <input type="text" name="mobile" id="mobile" placeholder="请输入手机号码/邀请码">
                <!--   <img src="/style/images/transfer/m2.jpg" alt=""> -->
            </dd>
            <dd>
                <i>转入姓名：</i>
                <input type="text" id="m_name" name="m_name" value="" placeholder="" disabled>
                <!--  <img src="/style/images/transfer/m2.jpg" alt=""> -->
            </dd>
            <dd>
                <i>转出数量：</i>
                <input type="text" name="number" id="number" placeholder="0">
               <!--  <img src="/style/images/transfer/m2.jpg" alt=""> -->
            </dd>

        </dl>
    </div>
    <input type="hidden" name="act" value="sub_transfer">
    <div class="b-btn" onClick="sub()">确认转出</div>
 </form>
</body>
<script>
var xidou_money = <?=$this->data['money']  ? :0;?>,
ximi_money = <?=$this->data['ximi_money'] ? :0;?>,
money = xidou_money,
gold_money = <?=$this->data['gold_money'];?>;
$("input[name=type]").click(function(){
	var type = $(this).val();
	if(type ==1){
		money = xidou_money;
	    $("#user_money").html(xidou_money);
	    $("#user_text").html("硒豆余额");
	}else if(type ==2){
        money = ximi_money;
        $("#user_money").html(ximi_money);
        $("#user_text").html("硒米余额");
    }else if(type ==3){
        money = gold_money;
        $("#user_money").html(gold_money);
        $("#user_text").html("金花余额");
    }

	
})

$("input[name=mobile]").on('blur', function(){
    if($(this).val()){
        $.ajax({
            type: 'post',
            url: 'ajax',
            data: {"act":"get_name","mr": Math.random(),'mobile':$("#mobile").prop("value")},
            dataType: 'json',
            success: function(data) {
                $("input[name=m_name]").val(data);

            }
        });
    }
})

    function sub() {
         

         if($("#mobile").prop("value") ==""){
        	 swal("请填写转账手机号码");
               return false;
           }
/*         pm = /^(13|14|15|16|17|18|19)([0-9]{9})$/;
         if (!pm.test($("#mobile").prop("value"))) {
             swal("手机号码格式不正确");
             return false;
         }*/


         if($("#number").prop("value") =="" || $("#number").prop("value") <1){
        	 swal("填写转账数量");
             return false;

         }
         if(isNaN($("#number").prop("value"))){
        	 swal("转账数量必须是数字");
             return false;
         }
         if(parseInt($("#number").prop("value")) >money){
        	 swal("转账数量不能大于余额");
             return false;

         }

         $.ajax({
             type: 'post',
             url: 'ajax',
             data: $("#form_tx").serialize() + "&mr=" + Math.random(),
             dataType: 'json',
             success: function(data) {
                     if (data.code == 200) {
                         swal("转账成功", false, "success");
                         setTimeout(function(){
                           window.location.href = '/user';
                         },2000);
                     } else {
                    	    swal(data.msg+"["+data.code+"]",false,"error");
                     }
   
             }
         });

    }

</script>
</html>